import moment from 'moment'

function padNum(num, length) {
  length = length || 2
  return (Array(length).join("0") + num).slice(-length);
}
export const date2MonthDay = (time) => {
  let date = moment(time).format('YYYY-MM-DD').split('-')
  return `${date[1]}月${date[2]}日`
}

export const formatSencond2Minute = (sencond) => {
  var h = Math.floor(sencond / 3600 % 24);
  var m = Math.floor(sencond / 60 % 60);
  return padNum(h) + ":" + padNum(m);
}

export const formatSencond2MinuteSencond = (sencond) => {
  var h = Math.floor(sencond / 3600 % 24);
  var m = Math.floor(sencond / 60 % 60);
  var s = Math.floor(sencond % 60);
  return padNum(m) + '分' + padNum(s) + '秒';
}
